﻿using System;
using System.IO;
namespace Fjaspx.UI.Web
{
    public partial class Administrator_config_dll : System.Web.UI.Page
    {
        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void Page_Load(object sender, EventArgs e)
        {

            FileInfo[] file = GetFilelist(Server.MapPath("~/bin/"));
            for (int i = 0; i < file.Length; i++)
            {
                Label_bll.Text += file[i].Name + "<BR>";
                //System.Reflection.Assembly o = System.Reflection.Assembly.Load(file[i].Name);
                //Response.Write(o.GetName());       
            }
            try
            {
                FileInfo[] file_no = GetFilelist(Server.MapPath("~/bin/_bin"));
                for (int i = 0; i < file_no.Length; i++)
                {
                    Label_bll_.Text += file_no[i].Name + "<BR>";
                    //System.Reflection.Assembly o = System.Reflection.Assembly.Load(file[i].Name);
                    //Response.Write(o.GetName());       
                }
            }
            catch { Label_bll_.Text = "无未注册DLL<BR>";

            Fjaspx.Common.SystemCms.InsertErrLog("无未注册DLL错误！", Request.PhysicalPath);
            }
        }
        /// <summary>
        /// Gets the filelist.
        /// </summary>
        /// <param name="filePath">The file path.</param>
        /// <returns></returns>
        public FileInfo[] GetFilelist(string filePath)//返回文件列表，filePath为根目录路径
        {
            //int filecounts = 0;//定义一个变量，表示文件数目
            FileInfo[] NewFileInfo;//定义一个数组，储存找到的文件并作为返回值
            DirectoryInfo FatherDirectory = new DirectoryInfo(filePath); //创建一个当前目录的实例
            //NewFileInfo = FatherDirectory.GetFiles("*.*", SearchOption.AllDirectories);
            NewFileInfo = FatherDirectory.GetFiles("*.dll");
            //得到文件集，包括目录及其子目录下的所有txt文件，如果用"*.*"就可以获得全部文件了
            //为了得到其他类型的文件，又写了下面的语句
            //AddNewArray<FileInfo>(ref NewFileInfo, FatherDirectory.GetFiles("*.mp3", SearchOption.AllDirectories));
            //把另一个查询记录并入到这个文件列表里
            return NewFileInfo;//返回文件列表
        }

    }
}